<template>
	<view>
		<view class="headtop"></view>
		<view class="headtitle flexbetween">
			<u-icon name="arrow-left" color="#333" size="26" @click="backpage"></u-icon>
			<view class="sanshier flexcenter fonweight xiaohei">{{returnflag()}}</view>
			<view class="" style="width: 40rpx;"></view>
		</view>
		<view class="" style="position: fixed;top: 150rpx;width: 100%;z-index: 3;">
			<scroll-view scroll-y="true" style="height: 85vh;">
				<view class="mainpadding">
					<view class="mainpadding ffffff radius">
						<view class="xiaohei sanshier fonweight">缘主姓名</view>
						<view class="borderinput margin_top radius mainpadding2s flexbetween">
							<input type="text" placeholder="请输入姓名" v-model="name">
							<u-icon name="arrow-right" color="#938F90"></u-icon>
						</view>
						<view class="xiaohei sanshier margin_top fonweight">性别</view>
						<view class="flexbetween">
							<view :class="sex==0?'xuanzhong':'weixuanz'" @click="sex=0" style="width: 45%;">男</view>
							<view :class="sex==1?'xuanzhong':'weixuanz'" @click="sex=1" style="width: 45%;">女</view>
						</view>
						<view class="xiaohei sanshier margin_top fonweight">日期类型</view>
						<view class="flexbetween">
							<view :class="type==0?'xuanzhong':'weixuanz'" @click="type=0" style="width: 45%;">农历</view>
							<view :class="type==1?'xuanzhong':'weixuanz'" @click="type=1" style="width: 45%;">公历</view>
						</view>
						<view class="xiaohei sanshier margin_top fonweight">出生日期</view>
						<view class="borderinput margin_top radius mainpadding2s flexbetween" @click="selecttime(1)">
							<input type="text" placeholder="请选择出生日期" disabled="" v-model="bir">
							<u-icon name="arrow-right" color="#938F90"></u-icon>
						</view>
						<view class="xiaohei sanshier margin_top fonweight">时辰</view>
						<view class="borderinput margin_top radius mainpadding2s flexbetween" @click="selecttime(2)">
							<input type="text" placeholder="请选择时辰" disabled="" v-model="shichen">
							<u-icon name="arrow-right" color="#938F90"></u-icon>
						</view>
						<view class="xiaohei sanshier margin_top fonweight">流派</view>
						<!-- <view class="borderinput margin_top radius mainpadding2s flexbetween">
							<input type="text" placeholder="请选择流派" disabled="" v-model="sect">
							<u-icon name="arrow-right" color="#938F90"></u-icon>
						</view> -->
						<view class="flexbetween">
							<view :class="sect==0?'xuanzhong':'weixuanz'" @click="sect=0" style="width: 45%;">晚子时日柱算明天
							</view>
							<view :class="sect==1?'xuanzhong':'weixuanz'" @click="sect=1" style="width: 45%;">晚子时日柱算当天
							</view>
						</view>
						<view class="xiaohei sanshier margin_top fonweight">是否真太阳时</view>
						<view class="flexbetween">
							<view :class="zhen==0?'xuanzhong':'weixuanz'" @click="zhen=0" style="width: 45%;">考虑真太阳时
							</view>
							<view :class="zhen==1?'xuanzhong':'weixuanz'" @click="zhen=1" style="width: 45%;">不考虑真太阳时
							</view>
						</view>
						<view class="xiaohei sanshier margin_top fonweight">地区</view>
						<view class="borderinput margin_top radius mainpadding2s flexbetween"
							@click="pickerdzshow=true">
							<input type="text" placeholder="请选择地区" disabled="" v-model="city_text">
							<u-icon name="arrow-right" color="#938F90"></u-icon>
						</view>
					</view>
					<view class="bigbtn margin_top6" @click="submit">立即测算</view>
				</view>
			</scroll-view>
		</view>

		<pickercity :messageInfo="{pickerdzshow:pickerdzshow}" @surecity="surecity"></pickercity>

		<timePicker :messageTime="messageTime" @timeConfirm="timeConfirm"></timePicker>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listtype: 1, //八字排盘，2八字精算，3紫薇排盘
				messageTime: {
					title: "选择出生年月",
					mode: "date",
					timeShow: false
				},
				currenttimeType: 1, //1日期，2时辰
				pickerdzshow: false,
				name: "",
				sex: 0,
				type: 0,
				bir: "",
				shichen: "",
				sect: 0,
				zhen: 0,
				province: "",
				city: "",
				city_text: ""

			}
		},
		onLoad(options) {
			this.listtype = options.type
		},
		methods: {
			returnflag(){
				if(this.listtype==1) return "八字排盘"
				if(this.listtype==2) return "八字精算"
				if(this.listtype==3) return "紫薇排盘"
			},
			submit() {
				if (this.name == "") {
					httpRequest.toast("请输入姓名")
					return false
				}
				if (this.bir == "") {
					httpRequest.toast("请选择出生年月")
					return false
				}
				if (this.shichen == "") {
					httpRequest.toast("请选择时辰")
					return false
				}
				if (this.province == "") {
					httpRequest.toast("请选择地区")
					return false
				}
				// jumpurl('/pages/index/bazijs')
				let obj = {
					data: {
						name: this.name,
						sex: this.sex,
						type: this.type,
						year: this.bir.split('-')[0],
						month: this.bir.split('-')[1],
						day: this.bir.split('-')[2],
						hours: this.shichen.split(':')[0],
						minute: this.shichen.split(':')[1],
						sect: this.sect,
						zhen: this.zhen,
						province: this.province,
						city: this.city,
					},
					url: "/api/Smcl/baziPaipanCl"
				}
				if(this.listtype==1){
					uni.navigateTo({
						url:"/pages/index/cesuanjg?msg="+encodeURIComponent(JSON.stringify(obj))
					})
				}
				if(this.listtype==2){
					obj.url = "/api/Smcl/bazijingsuanCl"
					uni.navigateTo({
						url:"/pages/index/bazijs?msg="+encodeURIComponent(JSON.stringify(obj))
					})
				}
				if(this.listtype==3){
					obj.url = "/api/Smcl/bazizwpanCl"
					uni.navigateTo({
						url:"/pages/index/ziweipp?msg="+encodeURIComponent(JSON.stringify(obj))
					})
				}
			},
			selecttime(val) {
				if (val == 1) {
					this.messageTime = {
						title: "选择出生年月",
						mode: "date",
						timeShow: true
					}
				} else {
					this.messageTime = {
						title: "选择时辰",
						mode: "time",
						timeShow: true
					}
				}
				this.currenttimeType = val
			},
			surecity(e) {
				this.pickerdzshow = false
				console.log(e);
				if(e){
					this.city_text = e.provence + "-" + e.city
					this.province = e.provenceid
					this.city = e.cityid
				}
			},
			timeConfirm(e) {
				console.log(e);
				if (this.currenttimeType == 1) {
					this.bir = e
				} else {
					this.shichen = e
				}
			},

		}
	}
</script>

<style lang="scss">
	.headtop {
		background-image: url("@/static/system/suangua.png");
		background-size: 100% 100%;
		width: 100%;
		height: 350rpx;
		position: fixed;
		top: 0;
		right: 0;
		z-index: 2;
	}

	.headtitle {
		position: fixed;
		top: 0;
		right: 0;
		z-index: 3;
		width: 100%;
		height: 150rpx;
		padding: 0 40rpx;
		box-sizing: border-box;
	}
</style>